﻿using Microsoft.Xna.Framework;
using XNAGameEngine.GameObject;

namespace XNAGameEngine.Collision
{
    /// <summary>
    /// This class is used to populate the current information of an object
    /// right during a collision event.  This is useful in that when
    /// the first object is notified of a collision; it could change its values
    /// before the 2nd object is notified of the collision and attempts
    /// to get the first object's information (which has been updated)
    /// which would/could result in incorrect calculations.
    /// </summary>
    public struct CollisionMessage
    {
        /// <summary>
        /// The value of the unique integer identifier for this object at the 
        /// time of the collision event
        /// </summary>
        public readonly int _objectId;

        /// <summary>
        /// The origin of the object at the time of the collision event
        /// </summary>
        public Vector2 _origin;

        /// <summary>
        /// Position of the object on screen at the time of the collision event
        /// </summary>
        public Vector2 _position;

        /// <summary>
        /// Positional velocity of the object at the time of the collision event
        /// </summary>
        public Vector2 _posVelocity;

        /// <summary>
        /// Positional acceleration of the object at the time of the collision event
        /// </summary>
        public Vector2 _posAcceleration;

        /// <summary>
        /// The ange value of the object at the time of the collision event, in degrees, 
        /// to rotate around the origin
        /// </summary>
        public double _angle;

        /// <summary>
        /// Angular velocity of the object at the time of the collision event
        /// (how many degrees it rotates per second)
        /// </summary>
        public double _angVelocity;

        /// <summary>
        /// Rotational acceleration of the object at the time of the collision event
        /// </summary>
        public double _angAcceleration;

        /// <summary>
        /// This is the default constructor for this class.  It is used to
        /// populate the information of the offending gameobject.
        /// </summary>
        /// <param name="objIn">object 2 in a collision with object 1</param>
        public CollisionMessage(GameObject2D objIn)
        {
            _objectId        = objIn._objectId;
            _origin          = objIn._origin;
            _position        = objIn._position;
            _posVelocity     = objIn._posVelocity;
            _posAcceleration = objIn._posAcceleration;
            _angle           = objIn._angle;
            _angVelocity     = objIn._angVelocity;
            _angAcceleration = objIn._angAcceleration;
        }
    }
}
